﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;
using IBatisNet.DataMapper;

namespace AUV5.DAL.Dao
{
	/// <summary>
	/// 功能：     ExtraService业务接口的实现
	/// 作者：     LI
 	/// 日期：     12/11/2011
 	/// 修改日期： 
 	/// 修改人：
 	/// 修改内容：
	/// </summary>
	public class ExtraServiceSqlMapDao : BaseSqlMapDao,IExtraServiceDao
	{
		private static ExtraServiceSqlMapDao instance =null;
		private static object syncRoot = new object();
		
		private ExtraServiceSqlMapDao ()
		{
			//
			// TODO: 此处添加ExtraServiceSqlMapDao的构造函数
			//
		}
		public static IExtraServiceDao Instance
        {
            get 
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new ExtraServiceSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

		/// <summary>
		/// 得到最大行数
		/// </summary>
		/// <returns></returns>
		public int GetMaxCounts()
		{
			try
			{
				return (int)ExecuteQueryForObject("SelectExtraServiceByMaxCounts",null);
			}
            catch
            {
                throw;
            }
		}

		/// <summary>
		/// 得到列表
		/// </summary>
		/// <returns></returns>
		public System.Collections.Generic.IList<ExtraService> GetList()
		{
			try
			{
				return ExecuteQueryForList<ExtraService>("SelectExtraService",null);
			}
            catch
            {
                throw;
            }
		}
		
		/// <summary>
		/// 通过不同参数得到列表
		/// </summary>
		/// <param name="objParameters"></param>
		/// <returns></returns>
		public System.Collections.Generic.IList<ExtraService> GetListByParameters(object objParameters)
		{
			try
			{
				return ExecuteQueryForList<ExtraService>("SelectExtraServiceByParameters",objParameters);
			}
            catch
            {
                throw;
            }
		}
		
		/// <summary>
		/// 得到明细
		/// </summary>
		/// <param name="ExtraID"></param>
		/// <returns></returns>
		public ExtraService GetDetail(System.String extraid)
		{
			try
			{
				return ExecuteQueryForObject<ExtraService>("SelectExtraService",extraid) as ExtraService;
			}
            catch
            {
                throw;
            }
		}
		
		/// <summary>
        /// 新建
        /// </summary>
        /// <param name="extraservice"></param>
        /// <returns></returns>
		public object Add(ExtraService extraservice)
		{
			//int id = GetId("ExtraService");
			//extraservice.ExtraID = id;
			
			try
			{
				return ExecuteInsert("InsertExtraService",extraservice);
			}
            catch
            {
                throw;
            }
		}
		
		/// <summary>
        /// 修改
        /// </summary>
        /// <param name="extraservice"></param>
        /// <returns></returns>
		public int Update(ExtraService extraservice)
		{
			try
			{
				return ExecuteUpdate("UpdateExtraService",extraservice);
			}
            catch
            {
                throw;
            }			
		}

		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="ExtraID"></param>
		/// <returns></returns>
		public int Delete(System.String extraid)
		{
			try
			{
				return ExecuteDelete("DeleteExtraService",extraid);
			}
            catch
            {
                throw;
            }
		}
		/// <summary>
		/// 删除
		/// </summary>
		/// <param name="extraservice"></param>
		/// <returns></returns>
		public int Delete(ExtraService extraservice)
		{
			try
			{
				return ExecuteDelete("DeleteExtraService",extraservice.ExtraID);
			}
            catch
            {
                throw;
            }
		}


        /// <summary>
        ///判断一条服务是否已经存在
        /// </summary>
        /// <param name="service"></param>
        /// <returns></returns>
        public bool isExists(ExtraService service)
        {
            try
            {
                return ExecuteQueryForObject("SelectByExtraService", service) != null;
            }
            catch (Exception)
            {
                
                throw;
            }
        }
	}
}
